﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Portal.Xml.Utility;

namespace Portal.Systems.Model
{
    public class UserQuickLinkCls
    {
        public string UserQuickLinkId;
        public string frkUserId;
        public string ObjectId;
        public string Subject;
        public string LinkUrl;
        public string LinkType;
        public int SortIndex;
    }

    public class UserQuickLinkParser
    {
        public static UserQuickLinkCls CreateInstance()
        {
            //tao 1 class trang....
            UserQuickLinkCls oUserQuickLinkCls = new UserQuickLinkCls();
            return oUserQuickLinkCls;
        }

        public static UserQuickLinkCls ParseFromXml(string XmlData)
        {
            DataSet ds = XmlUtility.GetDataSetFromXml(XmlData);
            UserQuickLinkCls oUserQuickLinkCls = ParseFromDataRow(ds.Tables[0].Rows[0]);
            return oUserQuickLinkCls;
        }


        public static UserQuickLinkCls ParseFromDataRow(DataRow dr)
        {
            UserQuickLinkCls OUserQuickLinkCls = new UserQuickLinkCls();
            OUserQuickLinkCls.UserQuickLinkId = (string)dr["UserQuickLinkId"];
            OUserQuickLinkCls.frkUserId = (string)dr["frkUserId"];
            OUserQuickLinkCls.ObjectId = (string)dr["ObjectId"];
            OUserQuickLinkCls.Subject = (string)dr["Subject"];
            OUserQuickLinkCls.LinkUrl = (string)dr["LinkUrl"];
            OUserQuickLinkCls.SortIndex = (int)dr["SortIndex"];
            OUserQuickLinkCls.LinkType = (string)dr["LinkType"];
            return OUserQuickLinkCls;
        }

        public static UserQuickLinkCls[] ParseFromDataTable(DataTable dtTable)
        {
            UserQuickLinkCls[] UserQuickLinks = new UserQuickLinkCls[dtTable.Rows.Count];
            for (int iIndex = 0; iIndex < dtTable.Rows.Count; iIndex++)
            {
                UserQuickLinks[iIndex] = ParseFromDataRow(dtTable.Rows[iIndex]);
            }

            return UserQuickLinks;
        }
    }
}


